package com.xiaoKe.zhonghzu.ui.mine;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import com.xiaoKe.zhonghzu.R;
import com.xiaoKe.zhonghzu.databinding.FragmentChangPassWordBinding;
import com.xiaoKe.zhonghzu.global.base.BaseFragment;
import com.xiaoKe.zhonghzu.global.tool.ToastUtils;
import com.xiaoKe.zhonghzu.ui.onClick.NoDoubleClickListener;


/**
 * @ProjectName : app
 * @Author : Shijingna
 * @Time : 2023/3/15 1:50 下午
 * @Description : 修改密码
 */
public class ChangePassWordFragment extends BaseFragment<FragmentChangPassWordBinding> {

    @Override
    protected void initView() {


    }

    @Override
    protected void initData() {
        NoDoubleClickListener noDoubleClickListener = new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View view) {
                switch (view.getId()) {
                    case R.id.tv_affirm: //确认
                        if (TextUtils.isEmpty(binding.edPassword.getText().toString().trim())) {
                            ToastUtils.showLong(getResources().getString(R.string.请输入原密码));
                        } else if (TextUtils.isEmpty(binding.edNewPassWord.getText().toString().trim())) {
                            ToastUtils.showLong(getResources().getString(R.string.新密码错误不能为空));
                        } else if (binding.edNewPassWord.getText().toString().trim().length() < 6) {
                            ToastUtils.showLong(getResources().getString(R.string.密码长度不能小于六位));
                        } else if (!binding.edNewPassWord.getText().toString().equals(binding.edAgainPassWord.getText().toString().trim())) {
                            ToastUtils.showLong(getResources().getString(R.string.两次密码不相同));
                        } else {
//                            getData();
                        }


                        break;
                }
            }
        };
        getView().findViewById(R.id.tv_affirm).setOnClickListener(noDoubleClickListener);

    }
//    private void getData() {
//        LogUtils.e(SPUtils.getString(getContext(), "token", ""));
//        RequestParams requestParams = new RequestParams();
//        requestParams.params.put("password", binding.edNewPassWord.getText().toString().trim().replace("\n", "").replace("\t", ""));
//        requestParams.params.put("id", SPUtils.getString(getContext(), "userId", ""));
//        requestParams.params.put("verificationPassWord", binding.edPassword.getText().toString().trim().replace("\n", "").replace("\t", ""));
//        requestParams.tag = "修改密码";
//        requestParams.type = "put";
//        requestParams.url = UrlUtils.USERRESETPWD;
//        AppManager.getInstance().getRequest().objectHttp(requestParams, ObjectData.class)
//                .compose(this.<ObjectData>bindToLifecycle())
//                .observeOn(AndroidSchedulers.mainThread())
//                .subscribe(new Subscriber<ObjectData>() {
//                    @Override
//                    public void onCompleted() {
//
//                    }
//
//                    @Override
//                    public void onError(Throwable e) {
//                        e.printStackTrace();
//                    }
//
//                    @Override
//                    public void onNext(ObjectData baseResponseBean) {
//                        if (baseResponseBean != null) {
//                            if (baseResponseBean.isSucceeded()) {
//                                Intent intent = new Intent(BaseApplication.instance, LoginActivity.class);
//                                SPUtils.putString(BaseApplication.instance, "token", ""); //清空token
//                                intent.setFlags(intent.FLAG_ACTIVITY_CLEAR_TASK | intent.FLAG_ACTIVITY_NEW_TASK);//退出要弹站
//                                BaseApplication.instance.startActivity(intent);
//                                getActivity().finish();
//                            }
//                            ToastUtils.showToast(baseResponseBean.getMsg());
//                        }
//
//                    }
//                });
//
//
//    }
}
